home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / array / stringcat.c < prev    next >
C/C++ Source or Header  |  2001-05-12  |  672b  |  41 lines

  1.  
  2. #include "tek/array.h"
  3.  
  4. /* 
  5. **    TEKlib
  6. **    (C) 2001 TEK neoscientists
  7. **    all rights reserved.
  8. **
  9. **    TBOOL TStringCat(TSTRPTR *s1, TSTRPTR s2)
  10. **    i0               p0           p1
  11. **
  12. **    catenate dynamic strings.
  13. **
  14. */
  15.  
  16. TBOOL TStringCat(TSTRPTR *s1, TSTRPTR s2)
  17. {
  18.     if (*s1 && s2)
  19.     {
  20.         TARRAY *a1 = *((TARRAY **) s1) - 1;
  21.         TARRAY *a2 = ((TARRAY *) s2) - 1;
  22.         
  23.         if (a1->valid && a2->valid)
  24.         {
  25.             TUINT addlen = a2->len - 1;
  26.             if (addlen)
  27.             {
  28.                 TUINT oldlen = a2->len - 1;
  29.                 if (TArraySetLen((TAPTR *) s1, oldlen + addlen + 1))
  30.                 {
  31.                     TMemCopy(s2, *s1 + oldlen, addlen + 1);
  32.                     return TTRUE;
  33.                 }
  34.                 return TFALSE;
  35.             }
  36.             return TTRUE;
  37.         }
  38.     }
  39.     return TFALSE;
  40. }
  41.